#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# @author: jianping.gao
# @date: 2023-09-01 14:01:55
# @desc:
from typing import List
from fastapi import APIRouter
from loguru import logger
from sqlalchemy.orm import Session
from fastapi import Depends
from app.providers.database_provider import get_db
from app.models.dto.project_sale_strategy import ProjectSaleStrategyQueryReq, ProjectSaleStrategyReq,ProjectSaleStrategyResp
from app.models.result import Result
from app.service.project_sale_strategy import ProjectSaleStrategyService

router = APIRouter( prefix="/saleStrategy/subProject")

#
# controller
# 
@router.post("/subProject/add",response_model=ProjectSaleStrategyResp,summary="新增销售策略")
async def add_sub_project(request: ProjectSaleStrategyReq,db: Session = Depends(get_db)):
    return "welcome to user"

@router.post("/subProject/list",response_model=Result[List[ProjectSaleStrategyResp]],summary="子项目销售策略列表")
async def sub_project_list(request: ProjectSaleStrategyQueryReq,db: Session = Depends(get_db)):
    list=ProjectSaleStrategyService().get_sub_project_list(request,db)
    return Result.success(data=list)

@router.post("/subProject/snaphost/list",response_model=Result[List[ProjectSaleStrategyResp]],summary="子项目销售策略快照列表")
async def sub_project_snaphost_list(request: ProjectSaleStrategyQueryReq,db: Session = Depends(get_db)):
    list=ProjectSaleStrategyService().get_sub_project_snapshot_list(request,db)
    return Result.success(data=list)
